/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.velocityme.session;

import com.velocityme.entity.SystemProperty;
import java.net.URL;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;

/**
 *
 * @author rcrida
 */
@Stateful
public class ServerConfigurationBean implements ServerConfigurationLocal {

    @PersistenceContext
    private EntityManager em;

    public String getClientGUID() {
        SystemProperty clientGUID = (SystemProperty) em.createNamedQuery("findSystemPropertyByName").
                setParameter("name", "client.guid").
                getSingleResult();
        return clientGUID.getValue();
    }

    public String getOwnerOrganisation() {
        try {
            SystemProperty organisation = (SystemProperty) em.createNamedQuery("findSystemPropertyByName").
                    setParameter("name", "owner.organisation").
                    getSingleResult();
            return (String) organisation.getValue();
        } catch (NoResultException ex) {
            return "Unitialized";
        }
    }

    public URL getOwnerOrganisationURL() {
        return null;
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add Operation")
    
}
